Skip to content

fix: Fix masking in single element screenshots. #1825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

janne-hyoetylae-med
Copy link
Contributor

Using masks in single element screenshots (Locator.screenshot()) never worked, because the mask option failed to be serialized.

When a mask is provided as an option, serialize it manually. This is the same implementation as in PageImpl.screenshot().

Fixes #1790

@janne-hyoetylae-med
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Medartis AG"

@mxschmitt mxschmitt requested a review from yury-s August 1, 2025 08:39
Using masks in single element screenshots (`Locator.screenshot()`) never worked, because the mask option failed to be serialized.

Add a serializer for `LocatorImpl`, so that this works everywhere correctly.

Fixes microsoft#1790
@@ -146,6 +146,17 @@ void maskShouldWork() {
assertThrows(AssertionFailedError.class, () -> assertArrayEquals(screenshot, originalScreenshot));
}

@Test
void maskShouldWorkForLocator() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: We should have migrated more mask tests from upstream while adding the feature, it would help to avoid bugs like this one.

@yury-s yury-s merged commit f83c03a into microsoft:main Aug 11, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Locator screenshot with mask always fails - serialization bug
2 participants